package at.sysarch.filter;

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;

import at.sysarch.utils.ImageChangedEvent;
import at.sysarch.utils.ImageChangedListener;

public class FileSave extends AbstractListenerManager implements ImageChangedListener {
	private String _fileName = "filteredImage";
	private PlanarImage _image = null;

	public PlanarImage getImage() {
		return _image;
	}

	public void setInputImage(PlanarImage image) {
		_image = image;
		updateImage();
	}

	private void updateImage() {
		JAI.create("filestore", _image, _fileName+".jpg", "JPEG");
	}

	public String getFileName() {
		return _fileName;
	}

	public void setFileName(String fileName) {
		_fileName = fileName;
		updateImage();

	}

	@Override
	public void imageChanged(ImageChangedEvent event) {
		setInputImage(event.getImage());
	}
}
